﻿@using Website.CRUDServices
@using Website.Models.Styling
@model Website.Models.ViewModels.ListView<NewsInformation>
@{
    this.ViewBag.Title = "Nyhedsinformation";
    this.Layout = "~/Views/_Shared/_Layout.cshtml";

    List<Project> Projects = this.ViewData["Projects"] as List<Project> ?? new List<Project>();
    List<NewsInformationType> Types = this.ViewData["Types"] as List<NewsInformationType> ?? new List<NewsInformationType>();
}

<div class="float-right smallMarginBottom">
    <input type="button" onclick="@string.Format("location.href = '{0}';", this.Url.Action("NewNewsInformation"))" value="Opret ny" class="" />
</div>

<table class="tableView">
    <tr>
        @foreach (TableViewHeaderItem item in this.Model.Header.Items)
        {
            <td>
                @Html.Partial("~/Views/_Shared/TableViewHeader.cshtml", item)
            </td>
        }
        <td></td>
    </tr>
    @if (this.Model != null)
    {
        foreach (NewsInformation news in this.Model.List)
        {
            <tr>
                <td>@string.Format("{0:dd-MM-yyyy}", news.TimeOfActivity)</td>
                <td>@news.Name</td>
            
                <td>
                    @if (Types.Where(x => x.ID == news.Type).Any())
                    {
                        @Types.SingleOrDefault(x => x.ID == news.Type).Name
                    }
                </td>
                <td>
                    @(news.IsInformationAboutFunds ? "Fonde/puljer" : string.Empty)
                    @(news.IsInformationAboutProgress ? "Fremdrift" : string.Empty)
                    @(news.IsInformationAboutResults ? "Resultater" : string.Empty)
                </td>
                <td>
                    @if (news.Comments.Length < 30)
                    {
                        @news.Comments
                    }
                    else
                    {
                        @(string.Format("{0}...", news.Comments.Substring(0, 30)))
                    }
                </td>

                <td><a href="@Url.Action("UpdateNewsInformation", new { @Id = news.ID })">
                        <img src="@Url.Content("~/Content/ButtonIcons/tool_blue.png")" alt="Link"/></a></td>
            </tr>
        }
    }


    <tr>
        @Html.Partial("~/Views/_Shared/PagingArrows.cshtml", new PagingArrows { Action = "Index", TotalAmountOfColumns = 6, CurrentSkip = this.Model.Skip, CurrentTake = this.Model.Take, CurrentTotalRowCount = this.Model.TotalRows })
    </tr>
</table>